const mongoose = require('mongoose');
require('mongoose-long')(mongoose);
let schemaTypes = mongoose.Schema.Types;

//日志schema
let logSchema = new mongoose.Schema({
    _id: {
        type: schemaTypes.ObjectId,
        require: true // 不可为空约束
	},
	//操作时间
	time:{
		type: schemaTypes.Long,
		require: true
	},
    //用户名
    userName: {
		type: String,
        require: true
    },
    //角色
    role: {
        type: String,
        require: true
    },
    //部门
    departmentName: {
        type: String,
        require: true
    },
    //单位
    orgName: {
        type: String,
        require: true
    },
    //操作
    operate: {
        type: String,
        require: true
    },
    //操作内容
    description: {
        type: String,
        require: true
    },
    //操作结果
    result: {
        type: String,
        require: true
    }
}, {
    versionKey: false
});

//日志model
let LogModel = mongoose.model('LogModel', logSchema, 'logs');
module.exports = LogModel;